<?php
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    $('#tmbh-item-div').toggle(false);
    return false;
});
$('#tmbh-item').click(function(){
	$('.search-form').toggle(false);
    $('#tmbh-item-div').toggle();
    return false;
});
$('.reset-button').click(function(){
    return true;
});

");

#---------------------------------------------------------------------------------------------------------------------------Menu_Operation
echo CHtml::link('Search','#',array('class'=>'search-button btn btn-success')).'&nbsp;';
echo CHtml::link('Add Item','#',array('class'=>'btn btn-success','id'=>'tmbh-item'));
?>
<div class="search-form" style="display:none;margin-top:10px">
    <table>
        <tr>
            <td>ID</td>
            <td><?php echo CHtml::textField('id','');?></td>
        </tr>
        <tr>
            <td>User Name</td>
            <td><?php echo CHtml::textField('user_name','');?></td>
        </tr>
       
    </table>

    <div class="form-actions">
        <?php
        echo CHtml::button('Search',array(
            'class'=>'btn btn-success',
            'onclick'=>"
                var id = $('#id').val();
                var user_name = $('#user_name').val();
                $.fn.yiiGridView.update(
                    'auth-user-grid',
                    {data: 'id='+id+'&user_name='+user_name}
                );
            "
        ));
        ?>
    </div>
</div>
<div class="row" id="tmbh-item-div" style="display:none;margin-top:10px">
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'type'=>'horizontal',
	'id'=>'mfaktur-form',
	'enableAjaxValidation'=>false,
)); ?>
    <style>
        .form-horizontal .control-group { margin-bottom: 5px; }
    </style>

<div class="span6">
	<?php echo $form->errorSummary($model); ?>
	<?php echo $form->textFieldRow($model,'user_name'); ?>
	<?php echo $form->textFieldRow($model,'password'); ?>


    <div class="control-group">
        <label class="control-label"></label>
        <div class="controls">
		    <?php echo CHtml::ajaxSubmitButton($model->isNewRecord ? 'Simpan' : 'Update',$this->createUrl('authuser/create'),array(
					'success'=>"function(data){
						ret = $.parseJSON(data);
						if (ret.status == 'ok') {
						    alert('Data Berhasil di simpan..');
						    location.reload();
							// $.fn.yiiGridView.update('voucher-bebas-grid');
						} else {
							alert(ret.msg);
						}
					}"
				),array('class'=>'btn btn-primary')
			); ?>
        </div>
    </div>
</div>
<?php $this->endWidget(); ?>
</div>


<?php $this->widget('bootstrap.widgets.TbGridView', array(
    'type'=>'striped bordered condensed',
	'id'=>'auth-user-grid',
    'dataProvider'=>$model->search(),
	#'filter'=>$model,
	'template'=>"{items}\n{pager}",
    'columns'=>array(
		array('header'=>'No','value'=>'++$row'),
		#'id',
		'user_name',
		'password',
		'status',
		/*'c_b',
		'c_d',
		
		'e_b',
		'e_d',
		*/
		/*array(
			'class'=>'CButtonColumn',
		),
		*/
	),
)); ?>